﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Windows.Media.Imaging;
using googlemaps;
using System.Threading;
using ClientMobile.SSVService;
using System.Device.Location;



namespace ClientMobile
{
    public partial class MainPage : PhoneApplicationPage
    {
     
        public GeoCoordinate Coords;
        // Constructor
        public MainPage()
        {
            InitializeComponent();


            Thread newThread = new Thread(MainPage.DoWork);
            newThread.Start();


            Singleton s = Singleton.Instance;
            Image img = new Image();
            //Image img4 = new Image();
            //Image img6 = new Image();
            //Image img5 = new Image();
            img.Source = new BitmapImage(new Uri(s.Chauff.Image, UriKind.RelativeOrAbsolute));
            //img4.Source = new BitmapImage(new Uri("Images/user.png", UriKind.RelativeOrAbsolute));
            //img5.Source = new BitmapImage(new Uri("Images/map.png", UriKind.RelativeOrAbsolute));
            //img6.Source = new BitmapImage(new Uri("Images/mail_send.png", UriKind.RelativeOrAbsolute));
            image1.Source = new BitmapImage(new Uri(s.Chauff.Image, UriKind.RelativeOrAbsolute));
            Nom.Text = s.Chauff.Nom;
            Prenom.Text = s.Chauff.Prenom;
            //button1.Content = img;
            ////button4.Content = img4;
            //pos.Content = img5;
            //mail.Content = img6;

            // Set the data context of the listbox control to the sample data
            DataContext = App.ViewModel;
            this.Loaded += new RoutedEventHandler(MainPage_Loaded);

        }


        private static void DoWork()
        {
            test insttick = new test();
            TimerCallback callback = new TimerCallback(insttick.Tick);

            // create a one second timer tick
            Timer stateTimer = new Timer(callback, null, 0, 5000);

            // loop here forever
            for (; ; ) { }

        }

     

        

    

        // Load data for the ViewModel Items
        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            if (!App.ViewModel.IsDataLoaded)
            {
                App.ViewModel.LoadData();
            }
        }



        private void button1_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Map.xaml", UriKind.Relative));
        }

        private void envoyer_mail(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/msg.xaml", UriKind.Relative));
        }

        private void profil_change(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Profile.xaml", UriKind.Relative));
        }

        private void envoi(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/sms.xaml", UriKind.Relative));
        }

        private void TextBlock_Tap(object sender, GestureEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Profile.xaml", UriKind.Relative));
        }

        private void TextBlock_Tap_1(object sender, GestureEventArgs e)
        {
            NavigationService.Navigate(new Uri("/msg.xaml", UriKind.Relative));
        }

        private void TextBlock_Tap_2(object sender, GestureEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Map.xaml", UriKind.Relative));
        }

        private void TextBlock_Tap_3(object sender, GestureEventArgs e)
        {
            NavigationService.Navigate(new Uri("/sms.xaml", UriKind.Relative));
        }

        private void but_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/sms.xaml", UriKind.Relative));
        }

        private void TextBlock_Tap_4(object sender, GestureEventArgs e)
        {
            NavigationService.Navigate(new Uri("/inbox.xaml", UriKind.Relative));
        }

        private void msgenv_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/outbox.xaml", UriKind.Relative));
        }


        private void TextBlock_Tap_6(object sender, GestureEventArgs e)
        {
            NavigationService.Navigate(new Uri("/outbox.xaml", UriKind.Relative));
        }

        private void msgrec_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/inbox.xaml", UriKind.Relative));
        }

        private void button1_Click_1(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/m_encours.xaml", UriKind.Relative));
        }

        private void TextBlock_Tap_5(object sender, GestureEventArgs e)
        {
            NavigationService.Navigate(new Uri("/m_encours.xaml", UriKind.Relative));
        }

        private void attente_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/m_enattente.xaml", UriKind.Relative));
        }

        private void TextBlock_Tap_7(object sender, GestureEventArgs e)
        {
            NavigationService.Navigate(new Uri("/m_enattente.xaml", UriKind.Relative));

        }

        private void button_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/mission.xaml", UriKind.Relative));
        }

        private void TextBlock_Tap_8(object sender, GestureEventArgs e)
        {
            NavigationService.Navigate(new Uri("/mission.xaml", UriKind.Relative));
        }

        private void mnoti_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Notifications.xaml", UriKind.Relative));
        }

        private void TextBlock_Tap_9(object sender, GestureEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Notifications.xaml", UriKind.Relative));
        }


    }

}